SlideShare ist ein Scribd-Unternehmen logo
1 von 42
Using Spring and MongoDB with
CloudFoundry

Josh Long
@starbuxman
Spring Developer Advocate
SpringSource, a division of VMware




                                     © 2009 VMware Inc. All rights reserved
About Josh Long


                  Spring Developer Advocate

                  @starbuxman
                  josh.long@springsource.com




                                         th
                                           si
                                            is
                                                im
                                                 po
                                                     rta
                                                      nt
                                                        !
                                    Free Book!
                                    SpringSource.org/roo




                                                            2
Spring




         3
Spring’s aim:
 bring simplicity to Java development
                                                             data
  web tier                                  integration
                                batch                       access
    &        service tier                        &                           mobile
                             processing                   / NoSQL /
   RIA                                      messaging
                                                          Big Data


                            The Spring framework
the cloud:                    lightweight                    traditional
     CloudFoundry                                                  WebSphere
                                          tc Server
       VMForce                                                      JBoss AS
                                           Tomcat
   Google App Engine                                               WebLogic
                                             Jetty
  Amazon Web Services                                          (on legacy versions, too!)




                                                                                            4
Spring Data




              5
Data Access Challenge #1: Scale Horizontally




                                               6
Data Access Challenge #2: Heterogeneous data access needs




                                                            7
New demands on data
               access
•... until we needed
inexpensive horizontal
scaling for some large web
based applications ...
• ... and we needed to
deploy our apps in the
cloud ...

                             * image courtesy of Bitcurrent   8
NoSQL offers several data store categories




Key-Value       Column          Document     Graph




  Redis,         Cassandra,       MongoDB    Neo4J
  Riak           HBase




                                                     9
NoSQL offers several data store categories




Key-Value       Column          Document                        Graph




                                  MongoDB
                                  (who cares about the rest?)




                                                                    10
Spring Framework
   built-in data access support
•Transaction abstractions
•Common data access exception hierarchy
•JDBC - JdbcTemplate
•ORM - Hibernate, JPA support
•OXM - Object to XML mapping
•Serializer/Deserializer strategies (Spring 3.0)
•Cache support (Spring 3.1)

                                                   11
http://www.springsource.org/spring-data

•Spring Data Key-value
•Spring Data Document
•Spring Data Graph
•Spring Data Column
•Spring Data Blob
•Spring Data JPA Repository / JDBC Extensions
•Spring Gemfire / Spring Hadoop ...
•Grails iNcOnSeQuentiaL
                                                12
Spring Data Building Blocks



•Low level data access APIs
   ✓MongoTemplate, RedisTemplate ...
•Object Mapping (Java and GORM)
•Cross Store Persistence Programming model
•Generic Repository support
•Productivity support in Roo and Grails

                                             13
Spring MongoDB




                 14
Spring Data Document
                Mongo
•MongoTemplate interface for mapping Mongo documents
  •MongoConverter
  •SimpleMongoConverter for basic POJO mapping support
  •Leverage Spring 3.0 TypeConverters and SpEL
  •Exception translation
•Advanced Mapping(@Document, @Id, @DbRef)
  •Annotation based
•MongoRepository
  •Built on Hades support for JPA Repositories
                                                         15
Simple Domain Class




                      16
Mongo Template

Direct Usage of the Mongo Template:




                                      17
Mongo Template

Direct Usage of the Mongo Template:




                 Insert into “Person”
                     Collection




                                        17
Mongo Template

Direct Usage of the Mongo Template:




           findOne using query: { "name" : "Joe"}
              in db.collection: database.Person




                                                    17
Mongo Template

Direct Usage of the Mongo Template:




          Dropped collection [database.person]




                                                 17
Generic Repository

Interface for generic CRUD operations on a repository for a specific type




                                                                            18
Paging and Sorting Repository


Paging and Sorting Repository:   Extends “CrudRepository”




                                                            19
Paging and Sorting Repository


Paging and Sorting Repository:   Extends “CrudRepository”




 Usage:




                                                            19
Custom Repository

Custom Repository:




                     20
Custom Repository

Custom Repository:




Keywords :
Keyword       Sample                               Logical result

GreaterThan   findByAgeGreaterThan(int age)        {"age" : {"$gt" : age}}

LessThan      findByAgeLessThan(int age)           {"age" : {"$lt" : age}}

Between       findByAgeBetween(int from, int to)   {"age" : {"$gt" : from, "$lt" : to}}

NotNull       findByFirstnameNotNull()             {”firstname" : {"$ne" : null}}

Null          findByFirstnameNull()                {”firstname" : null}

Like          findByFirstnameLike(String name)     "firstname" : firstname} (regex)
                                                                                 20
Cross Store




              21
JPA and MongoDB

 JPA “Customer” with a “SurveyInfo” Document




                                               22
Using a Cross-Store

  Saving a Customer with a SurveryInfo




                                         23
Using a Cross-Store

  Saving a Customer with a SurveryInfo
                           Create Customer




                                             23
Using a Cross-Store

  Saving a Customer with a SurveryInfo

                            Create SurveyInfo




                                                23
Using a Cross-Store

  Saving a Customer with a SurveryInfo




             Assign Survey to Customer




                                         23
Using a Cross-Store

  Saving a Customer with a SurveryInfo




                         Save




                                         23
Using a Cross-Store

  Saving a Customer with a SurveryInfo




                         Save




  Mongo Document:




                                         23
Cloud Foundry




                24
Cloud Foundry

   github.com/cloudfoundry
   cloudfoundry.org
   @cloudfoundry
   Supports:
    • Languages: Java, Scala, Node.js, Grails, Ruby/Rails/Sinatra, etc.
    • Services: MongoDB, Redis, MySQL, PostgreSQL, RabbitMQ
 ecosystem forks:
    • AppFog - PHP
    • Stacato: Python, Perl, etc., from ActiveState




                                                                          25
Choice of clouds




                                                               .js




                                                                       ce
                                                                     rfa
                       Ap




                                                                   te
         Data                                                              Private
                          p




                                                                 In
                              lic

        Services
                                                                           Clouds




                                                               er
                               at
                                io




                                                              vid
                                    n



                                                                     Public


                                                            o
                                    Se



                     Msg




                                                         Pr
                   Services
                                       r



                                                                     Clouds
                                          vic




                                                          d
                                                        ou
                                              e
                                             In


                                                      Cl

                                                              Micro
                                               te




                                Other
                                                  r




                               Services
                                                              Clouds
                                                  fa
                                                   e c




                                                                                     26
Choice of clouds




                                                               .js




                                                                       ce
                                                                     rfa
                       Ap




                                                                   te
         Data                                                              Private
                          p




                                                                 In
                              lic

        Services
                                                                           Clouds
                                                                                            …



                                                               er
                               at
                                io




                                                              vid
                                    n



                                                                     Public


                                                            o
                                    Se



                     Msg




                                                         Pr
                   Services
                                       r



                                                                     Clouds
                                          vic




                                                          d
                                                        ou
                                              e
                                             In




                                                                                     .COM
                                                      Cl

                                                              Micro
                                               te




                                Other
                                                  r




                               Services
                                                              Clouds
                                                  fa
                                                   e c




                                                                                            26
Setting up Cloud Foundry Demo




                                27
Accessing Services Bound to Cloud Foundry (producer)

private String mongoDatabaseServiceName = "survey-mongo";

@Bean
public CloudEnvironment cloudEnvironment() {
	   return new CloudEnvironment();
}

@Bean
public MongoServiceInfo mongoServiceInfo() {
	   return cloudEnvironment().getServiceInfo(
       mongoDatabaseServiceName, MongoServiceInfo.class);
}

@Bean
public MongoDbFactory mongoDbFactory() {
	   MongoServiceCreator msc = new MongoServiceCreator();
	   MongoDbFactory db = msc.createService(mongoServiceInfo());
}


                                                                 28
Accessing Services Bound to Cloud Foundry (consumption)


@Inject private Mongo mongo ;

@Inject private MongoTemplate mongoTemplate;




                                                          29
Cloud Foundry MongoDB Demo




                             30
Where to Find More

 Spring Data Project:
 http://bit.ly/spring-data
 CloudFoundry Samples:
 http://bit.ly/cloudfoundry-samples
 MicroCloud Foundry for Spring Developers
 http://bit.ly/mcf4spring
 Spring Data Mongo on Cloud Foundry (webinar, 12/01/2011)
 http://bit.ly/spring-mongo-cloudfoundry




                                                             31

Weitere ähnliche Inhalte

Was ist angesagt?

EBS and RBS in SharePoint 2010
EBS and RBS in SharePoint 2010EBS and RBS in SharePoint 2010
EBS and RBS in SharePoint 2010
Chris Geier
 
MongoDB et Hadoop
MongoDB et HadoopMongoDB et Hadoop
MongoDB et Hadoop
MongoDB
 

Was ist angesagt? (13)

MongodB Internals
MongodB InternalsMongodB Internals
MongodB Internals
 
FIWARE Global Summit - Hands-On NGSI-LD
FIWARE Global Summit - Hands-On NGSI-LDFIWARE Global Summit - Hands-On NGSI-LD
FIWARE Global Summit - Hands-On NGSI-LD
 
EBS and RBS in SharePoint 2010
EBS and RBS in SharePoint 2010EBS and RBS in SharePoint 2010
EBS and RBS in SharePoint 2010
 
Managing Social Content with MongoDB
Managing Social Content with MongoDBManaging Social Content with MongoDB
Managing Social Content with MongoDB
 
FIWARE Global Summit - NGSI-LD: Modelling, Linking and Utilizing Context Info...
FIWARE Global Summit - NGSI-LD: Modelling, Linking and Utilizing Context Info...FIWARE Global Summit - NGSI-LD: Modelling, Linking and Utilizing Context Info...
FIWARE Global Summit - NGSI-LD: Modelling, Linking and Utilizing Context Info...
 
Performance analysis of MongoDB and HBase
Performance analysis of MongoDB and HBasePerformance analysis of MongoDB and HBase
Performance analysis of MongoDB and HBase
 
MongoDB et Hadoop
MongoDB et HadoopMongoDB et Hadoop
MongoDB et Hadoop
 
Database Trends for Modern Applications: Why the Database You Choose Matters
Database Trends for Modern Applications: Why the Database You Choose Matters Database Trends for Modern Applications: Why the Database You Choose Matters
Database Trends for Modern Applications: Why the Database You Choose Matters
 
Python and MongoDB as a Market Data Platform by James Blackburn
Python and MongoDB as a Market Data Platform by James BlackburnPython and MongoDB as a Market Data Platform by James Blackburn
Python and MongoDB as a Market Data Platform by James Blackburn
 
Transitioning from SQL to MongoDB
Transitioning from SQL to MongoDBTransitioning from SQL to MongoDB
Transitioning from SQL to MongoDB
 
MongoDB World 2018: Bumps and Breezes: Our Journey from RDBMS to MongoDB
MongoDB World 2018: Bumps and Breezes: Our Journey from RDBMS to MongoDBMongoDB World 2018: Bumps and Breezes: Our Journey from RDBMS to MongoDB
MongoDB World 2018: Bumps and Breezes: Our Journey from RDBMS to MongoDB
 
Mongo-Drupal
Mongo-DrupalMongo-Drupal
Mongo-Drupal
 
Mongo db halloween party
Mongo db halloween partyMongo db halloween party
Mongo db halloween party
 

Andere mochten auch (10)

Extending spring
Extending springExtending spring
Extending spring
 
The spring 32 update final
The spring 32 update finalThe spring 32 update final
The spring 32 update final
 
Spring in-the-cloud
Spring in-the-cloudSpring in-the-cloud
Spring in-the-cloud
 
Multi Client Development with Spring
Multi Client Development with SpringMulti Client Development with Spring
Multi Client Development with Spring
 
Integration and Batch Processing on Cloud Foundry
Integration and Batch Processing on Cloud FoundryIntegration and Batch Processing on Cloud Foundry
Integration and Batch Processing on Cloud Foundry
 
Boot It Up
Boot It UpBoot It Up
Boot It Up
 
Bootiful Code with Spring Boot
Bootiful Code with Spring BootBootiful Code with Spring Boot
Bootiful Code with Spring Boot
 
Economies of Scaling Software
Economies of Scaling SoftwareEconomies of Scaling Software
Economies of Scaling Software
 
REST APIs with Spring
REST APIs with SpringREST APIs with Spring
REST APIs with Spring
 
Microservices with Spring Boot
Microservices with Spring BootMicroservices with Spring Boot
Microservices with Spring Boot
 

Ähnlich wie using Spring and MongoDB on Cloud Foundry

MongoDB + Java + Spring Data
MongoDB + Java + Spring DataMongoDB + Java + Spring Data
MongoDB + Java + Spring Data
Anton Sulzhenko
 
Java overview the piramide of success
Java overview the piramide of successJava overview the piramide of success
Java overview the piramide of success
Artem Bilan
 
Java Persistence Frameworks for MongoDB
Java Persistence Frameworks for MongoDBJava Persistence Frameworks for MongoDB
Java Persistence Frameworks for MongoDB
MongoDB
 
Hybrid MongoDB and RDBMS Applications
Hybrid MongoDB and RDBMS ApplicationsHybrid MongoDB and RDBMS Applications
Hybrid MongoDB and RDBMS Applications
Steven Francia
 
MongoDB for Java Devs with Spring Data - MongoPhilly 2011
MongoDB for Java Devs with Spring Data - MongoPhilly 2011MongoDB for Java Devs with Spring Data - MongoPhilly 2011
MongoDB for Java Devs with Spring Data - MongoPhilly 2011
MongoDB
 
MongoDB in FS
MongoDB in FSMongoDB in FS
MongoDB in FS
MongoDB
 

Ähnlich wie using Spring and MongoDB on Cloud Foundry (20)

MongoDB + Java + Spring Data
MongoDB + Java + Spring DataMongoDB + Java + Spring Data
MongoDB + Java + Spring Data
 
Spring in the Cloud - using Spring with Cloud Foundry
Spring in the Cloud - using Spring with Cloud FoundrySpring in the Cloud - using Spring with Cloud Foundry
Spring in the Cloud - using Spring with Cloud Foundry
 
Java Persistence Frameworks for MongoDB
Java Persistence Frameworks for MongoDBJava Persistence Frameworks for MongoDB
Java Persistence Frameworks for MongoDB
 
Java overview the piramide of success
Java overview the piramide of successJava overview the piramide of success
Java overview the piramide of success
 
Java Persistence Frameworks for MongoDB
Java Persistence Frameworks for MongoDBJava Persistence Frameworks for MongoDB
Java Persistence Frameworks for MongoDB
 
CloudFoundry and MongoDb, a marriage made in heaven
CloudFoundry and MongoDb, a marriage made in heavenCloudFoundry and MongoDb, a marriage made in heaven
CloudFoundry and MongoDb, a marriage made in heaven
 
Spring data presentation
Spring data presentationSpring data presentation
Spring data presentation
 
MongoDB Days UK: Building an Enterprise Data Fabric at Royal Bank of Scotland...
MongoDB Days UK: Building an Enterprise Data Fabric at Royal Bank of Scotland...MongoDB Days UK: Building an Enterprise Data Fabric at Royal Bank of Scotland...
MongoDB Days UK: Building an Enterprise Data Fabric at Royal Bank of Scotland...
 
Introducing MongoDB into your Organization
Introducing MongoDB into your OrganizationIntroducing MongoDB into your Organization
Introducing MongoDB into your Organization
 
MongoDB for Java Developers with Spring Data
MongoDB for Java Developers with Spring DataMongoDB for Java Developers with Spring Data
MongoDB for Java Developers with Spring Data
 
Hybrid MongoDB and RDBMS Applications
Hybrid MongoDB and RDBMS ApplicationsHybrid MongoDB and RDBMS Applications
Hybrid MongoDB and RDBMS Applications
 
Getting Started with MongoDB at Oracle Open World 2012
Getting Started with MongoDB at Oracle Open World 2012Getting Started with MongoDB at Oracle Open World 2012
Getting Started with MongoDB at Oracle Open World 2012
 
MongoDB for Java Devs with Spring Data - MongoPhilly 2011
MongoDB for Java Devs with Spring Data - MongoPhilly 2011MongoDB for Java Devs with Spring Data - MongoPhilly 2011
MongoDB for Java Devs with Spring Data - MongoPhilly 2011
 
No SQL at The Guardian
No SQL at The GuardianNo SQL at The Guardian
No SQL at The Guardian
 
MongoDB Versatility: Scaling the MapMyFitness Platform
MongoDB Versatility: Scaling the MapMyFitness PlatformMongoDB Versatility: Scaling the MapMyFitness Platform
MongoDB Versatility: Scaling the MapMyFitness Platform
 
NoSql presentation
NoSql presentationNoSql presentation
NoSql presentation
 
How to use NoSQL in Enterprise Java Applications - NoSQL Roadshow Zurich
How to use NoSQL in Enterprise Java Applications - NoSQL Roadshow ZurichHow to use NoSQL in Enterprise Java Applications - NoSQL Roadshow Zurich
How to use NoSQL in Enterprise Java Applications - NoSQL Roadshow Zurich
 
MongoDB in FS
MongoDB in FSMongoDB in FS
MongoDB in FS
 
Nosql Now 2012: MongoDB Use Cases
Nosql Now 2012: MongoDB Use CasesNosql Now 2012: MongoDB Use Cases
Nosql Now 2012: MongoDB Use Cases
 
Using MongoDB to Build a Fast and Scalable Content Repository
Using MongoDB to Build a Fast and Scalable Content RepositoryUsing MongoDB to Build a Fast and Scalable Content Repository
Using MongoDB to Build a Fast and Scalable Content Repository
 

Mehr von Joshua Long

Mehr von Joshua Long (19)

Have You Seen Spring Lately?
Have You Seen Spring Lately?Have You Seen Spring Lately?
Have You Seen Spring Lately?
 
Java Configuration Deep Dive with Spring
Java Configuration Deep Dive with SpringJava Configuration Deep Dive with Spring
Java Configuration Deep Dive with Spring
 
the Spring Update from JavaOne 2013
the Spring Update from JavaOne 2013the Spring Update from JavaOne 2013
the Spring Update from JavaOne 2013
 
Multi Client Development with Spring for SpringOne 2GX 2013 with Roy Clarkson
Multi Client Development with Spring for SpringOne 2GX 2013 with Roy ClarksonMulti Client Development with Spring for SpringOne 2GX 2013 with Roy Clarkson
Multi Client Development with Spring for SpringOne 2GX 2013 with Roy Clarkson
 
the Spring 4 update
the Spring 4 updatethe Spring 4 update
the Spring 4 update
 
Multi Client Development with Spring
Multi Client Development with SpringMulti Client Development with Spring
Multi Client Development with Spring
 
The Cloud Foundry bootcamp talk from SpringOne On The Road - Europe
The Cloud Foundry bootcamp talk from SpringOne On The Road - EuropeThe Cloud Foundry bootcamp talk from SpringOne On The Road - Europe
The Cloud Foundry bootcamp talk from SpringOne On The Road - Europe
 
A Walking Tour of (almost) all of Springdom
A Walking Tour of (almost) all of Springdom A Walking Tour of (almost) all of Springdom
A Walking Tour of (almost) all of Springdom
 
Multi client Development with Spring
Multi client Development with SpringMulti client Development with Spring
Multi client Development with Spring
 
Spring Batch Behind the Scenes
Spring Batch Behind the ScenesSpring Batch Behind the Scenes
Spring Batch Behind the Scenes
 
Cloud Foundry Bootcamp
Cloud Foundry BootcampCloud Foundry Bootcamp
Cloud Foundry Bootcamp
 
Spring and Cloud Foundry; a Marriage Made in Heaven
Spring and Cloud Foundry; a Marriage Made in HeavenSpring and Cloud Foundry; a Marriage Made in Heaven
Spring and Cloud Foundry; a Marriage Made in Heaven
 
Spring 3.1: a Walking Tour
Spring 3.1: a Walking TourSpring 3.1: a Walking Tour
Spring 3.1: a Walking Tour
 
Extending Spring for Custom Usage
Extending Spring for Custom UsageExtending Spring for Custom Usage
Extending Spring for Custom Usage
 
Using Spring's IOC Model
Using Spring's IOC ModelUsing Spring's IOC Model
Using Spring's IOC Model
 
Enterprise Integration and Batch Processing on Cloud Foundry
Enterprise Integration and Batch Processing on Cloud FoundryEnterprise Integration and Batch Processing on Cloud Foundry
Enterprise Integration and Batch Processing on Cloud Foundry
 
a Running Tour of Cloud Foundry
a Running Tour of Cloud Foundrya Running Tour of Cloud Foundry
a Running Tour of Cloud Foundry
 
Cloud Foundry, Spring and Vaadin
Cloud Foundry, Spring and VaadinCloud Foundry, Spring and Vaadin
Cloud Foundry, Spring and Vaadin
 
Messaging sz
Messaging szMessaging sz
Messaging sz
 

Kürzlich hochgeladen

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Kürzlich hochgeladen (20)

FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 

using Spring and MongoDB on Cloud Foundry

  • 1. Using Spring and MongoDB with CloudFoundry Josh Long @starbuxman Spring Developer Advocate SpringSource, a division of VMware © 2009 VMware Inc. All rights reserved
  • 2. About Josh Long Spring Developer Advocate @starbuxman josh.long@springsource.com th si is im po rta nt ! Free Book! SpringSource.org/roo 2
  • 3. Spring 3
  • 4. Spring’s aim: bring simplicity to Java development data web tier integration batch access & service tier & mobile processing / NoSQL / RIA messaging Big Data The Spring framework the cloud: lightweight traditional CloudFoundry WebSphere tc Server VMForce JBoss AS Tomcat Google App Engine WebLogic Jetty Amazon Web Services (on legacy versions, too!) 4
  • 6. Data Access Challenge #1: Scale Horizontally 6
  • 7. Data Access Challenge #2: Heterogeneous data access needs 7
  • 8. New demands on data access •... until we needed inexpensive horizontal scaling for some large web based applications ... • ... and we needed to deploy our apps in the cloud ... * image courtesy of Bitcurrent 8
  • 9. NoSQL offers several data store categories Key-Value Column Document Graph Redis, Cassandra, MongoDB Neo4J Riak HBase 9
  • 10. NoSQL offers several data store categories Key-Value Column Document Graph MongoDB (who cares about the rest?) 10
  • 11. Spring Framework built-in data access support •Transaction abstractions •Common data access exception hierarchy •JDBC - JdbcTemplate •ORM - Hibernate, JPA support •OXM - Object to XML mapping •Serializer/Deserializer strategies (Spring 3.0) •Cache support (Spring 3.1) 11
  • 12. http://www.springsource.org/spring-data •Spring Data Key-value •Spring Data Document •Spring Data Graph •Spring Data Column •Spring Data Blob •Spring Data JPA Repository / JDBC Extensions •Spring Gemfire / Spring Hadoop ... •Grails iNcOnSeQuentiaL 12
  • 13. Spring Data Building Blocks •Low level data access APIs ✓MongoTemplate, RedisTemplate ... •Object Mapping (Java and GORM) •Cross Store Persistence Programming model •Generic Repository support •Productivity support in Roo and Grails 13
  • 15. Spring Data Document Mongo •MongoTemplate interface for mapping Mongo documents •MongoConverter •SimpleMongoConverter for basic POJO mapping support •Leverage Spring 3.0 TypeConverters and SpEL •Exception translation •Advanced Mapping(@Document, @Id, @DbRef) •Annotation based •MongoRepository •Built on Hades support for JPA Repositories 15
  • 17. Mongo Template Direct Usage of the Mongo Template: 17
  • 18. Mongo Template Direct Usage of the Mongo Template: Insert into “Person” Collection 17
  • 19. Mongo Template Direct Usage of the Mongo Template: findOne using query: { "name" : "Joe"} in db.collection: database.Person 17
  • 20. Mongo Template Direct Usage of the Mongo Template: Dropped collection [database.person] 17
  • 21. Generic Repository Interface for generic CRUD operations on a repository for a specific type 18
  • 22. Paging and Sorting Repository Paging and Sorting Repository: Extends “CrudRepository” 19
  • 23. Paging and Sorting Repository Paging and Sorting Repository: Extends “CrudRepository” Usage: 19
  • 25. Custom Repository Custom Repository: Keywords : Keyword Sample Logical result GreaterThan findByAgeGreaterThan(int age) {"age" : {"$gt" : age}} LessThan findByAgeLessThan(int age) {"age" : {"$lt" : age}} Between findByAgeBetween(int from, int to) {"age" : {"$gt" : from, "$lt" : to}} NotNull findByFirstnameNotNull() {”firstname" : {"$ne" : null}} Null findByFirstnameNull() {”firstname" : null} Like findByFirstnameLike(String name) "firstname" : firstname} (regex) 20
  • 27. JPA and MongoDB JPA “Customer” with a “SurveyInfo” Document 22
  • 28. Using a Cross-Store Saving a Customer with a SurveryInfo 23
  • 29. Using a Cross-Store Saving a Customer with a SurveryInfo Create Customer 23
  • 30. Using a Cross-Store Saving a Customer with a SurveryInfo Create SurveyInfo 23
  • 31. Using a Cross-Store Saving a Customer with a SurveryInfo Assign Survey to Customer 23
  • 32. Using a Cross-Store Saving a Customer with a SurveryInfo Save 23
  • 33. Using a Cross-Store Saving a Customer with a SurveryInfo Save Mongo Document: 23
  • 35. Cloud Foundry  github.com/cloudfoundry  cloudfoundry.org  @cloudfoundry  Supports: • Languages: Java, Scala, Node.js, Grails, Ruby/Rails/Sinatra, etc. • Services: MongoDB, Redis, MySQL, PostgreSQL, RabbitMQ  ecosystem forks: • AppFog - PHP • Stacato: Python, Perl, etc., from ActiveState 25
  • 36. Choice of clouds .js ce rfa Ap te Data Private p In lic Services Clouds er at io vid n Public o Se Msg Pr Services r Clouds vic d ou e In Cl Micro te Other r Services Clouds fa e c 26
  • 37. Choice of clouds .js ce rfa Ap te Data Private p In lic Services Clouds … er at io vid n Public o Se Msg Pr Services r Clouds vic d ou e In .COM Cl Micro te Other r Services Clouds fa e c 26
  • 38. Setting up Cloud Foundry Demo 27
  • 39. Accessing Services Bound to Cloud Foundry (producer) private String mongoDatabaseServiceName = "survey-mongo"; @Bean public CloudEnvironment cloudEnvironment() { return new CloudEnvironment(); } @Bean public MongoServiceInfo mongoServiceInfo() { return cloudEnvironment().getServiceInfo( mongoDatabaseServiceName, MongoServiceInfo.class); } @Bean public MongoDbFactory mongoDbFactory() { MongoServiceCreator msc = new MongoServiceCreator(); MongoDbFactory db = msc.createService(mongoServiceInfo()); } 28
  • 40. Accessing Services Bound to Cloud Foundry (consumption) @Inject private Mongo mongo ; @Inject private MongoTemplate mongoTemplate; 29
  • 42. Where to Find More  Spring Data Project: http://bit.ly/spring-data  CloudFoundry Samples: http://bit.ly/cloudfoundry-samples  MicroCloud Foundry for Spring Developers http://bit.ly/mcf4spring  Spring Data Mongo on Cloud Foundry (webinar, 12/01/2011)  http://bit.ly/spring-mongo-cloudfoundry 31

Hinweis der Redaktion

  1. \n
  2. Hello, thank you or having me. Im pleased to have the opportunity to introduce you today to Spring and the SpringSource Tool Suite \n\nMy anem is Josh Long. I serve as the developer advocate for the Spring framework. I’ve used it in earnest and advocated it for many years now. i’m an author on 3 books on the technology, as well as a comitter to many of the Spring projects. Additionally, I take community activism very seriously and do my best to participate in the community. Sometimes this means answering question on Twitter, or in the forums, or helping contribute to the InfoQ.com and Artima.com communities\n
  3. \n
  4. these different framerworks let u tackle any problem youre likely to want to solve today \n- we support javee1.4 + 1.5 + 1.6; \n\nsits above target platform \nruns in cloud \n\n
  5. \n
  6. Oracle RAC clustering is very expensive. $70K/CPU according to list. Even at ½ the cost, it’s still really expensive to build out a horizontal data access grid. \n
  7. The amount of log data amassed in Facebook’s operations is staggering. Rothschild said Facebook manages more than 25 terabytes of data per day in logging data, which he said was the equivalent of about 1,000 times the volume of mail delivered daily by the U.S. Postal Service.\n\nBASE (basically available, soft state, eventually consistent)\n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n